﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace eCompany.eRules
{
    public class eCompanyRules
    {
        public static double getWorkProducedUnit(eCompany.eObj.company c, eCompany.eObj.employee e, int productivity)
        {
            double units = productivity /c.production_ratio/c.customized_point;

            return Math.Round(units);
        }

        public static double getProductModifier(eCompany.eObj.company_type_enum company_type)
        {
            double modifier = 0;

            switch (company_type)
            {
                case eCompany.eObj.company_type_enum.grain:
                    modifier = 2;
                    break;
                case eCompany.eObj.company_type_enum.oil:
                    modifier = 2;
                    break;
                case eCompany.eObj.company_type_enum.iron:
                    modifier = 2;
                    break;
                case eCompany.eObj.company_type_enum.stone:
                    modifier = 2;
                    break;
                case eCompany.eObj.company_type_enum.food:
                    modifier = 0.3;
                    break;
                case eCompany.eObj.company_type_enum.moving_tickets:
                    modifier = 2;
                    break;
                case eCompany.eObj.company_type_enum.weapons:
                    modifier = 2;
                    break;
                case eCompany.eObj.company_type_enum.house:
                    modifier = 25;
                    break;
                case eCompany.eObj.company_type_enum.defense_system:
                    modifier = 115;
                    break;
                case eCompany.eObj.company_type_enum.hospital:
                    modifier = 115;
                    break;
                default:
                    modifier = 2;
                    break;
            }
            return modifier;
        }

        public static bool isMaterialCompanyType(eCompany.eObj.company_type_enum company_type)
        {
            bool retval = false;
            switch (company_type)
            {
                case eCompany.eObj.company_type_enum.grain:
                    retval = true;
                    break;
                case eCompany.eObj.company_type_enum.oil:
                    retval = true;
                    break;
                case eCompany.eObj.company_type_enum.iron:
                    retval = true;
                    break;
                case eCompany.eObj.company_type_enum.stone:
                    retval = true;
                    break;
            }

            return retval;
        }

        public static eCompany.eObj.material_type_enum getCompanyRawType(eCompany.eObj.company_type_enum company_type)
        {
            eCompany.eObj.material_type_enum t = eObj.material_type_enum.Grain;

            switch (company_type)
            {
                case eCompany.eObj.company_type_enum.food:
                    t = eObj.material_type_enum.Grain;
                    break;
                case eCompany.eObj.company_type_enum.moving_tickets:
                    t = eObj.material_type_enum.Oil;
                    break;
                case eCompany.eObj.company_type_enum.weapons:
                    t = eObj.material_type_enum.Iron;
                    break;
                case eCompany.eObj.company_type_enum.house:
                    t = eObj.material_type_enum.Stone;
                    break;
                case eCompany.eObj.company_type_enum.defense_system:
                    t = eObj.material_type_enum.Stone;
                    break;
                case eCompany.eObj.company_type_enum.hospital:
                    t = eObj.material_type_enum.Stone;
                    break;
            }

            return t;
        }
        public static int getIndustryId(eObj.company_type_enum company_type)
        {
            switch (company_type)
            {
                case eCompany.eObj.company_type_enum.grain:
                    return 10;
                case eCompany.eObj.company_type_enum.oil:
                    return 11;
                case eCompany.eObj.company_type_enum.iron:
                    return 14;
                case eCompany.eObj.company_type_enum.stone:
                    return 13;
                case eCompany.eObj.company_type_enum.food:
                    return 1;
                case eCompany.eObj.company_type_enum.moving_tickets:
                    return 2;
                case eCompany.eObj.company_type_enum.weapons:
                    return 15;
                case eCompany.eObj.company_type_enum.house:
                    return 3;
                case eCompany.eObj.company_type_enum.defense_system:
                    return 5;
                case eCompany.eObj.company_type_enum.hospital:
                    return 4;
                default:
                    return 0;
            }
        }
        public static int getMaterialUse(eCompany.eObj.company_type_enum company_type, int custom_points)
        {
            if (company_type == eObj.company_type_enum.food)
            {
                if (custom_points == 20) return 6;
                if (custom_points == 40) return 12;
                if (custom_points == 60) return 18;
                if (custom_points == 80) return 24;
                return 30;
            }
            if (company_type == eObj.company_type_enum.moving_tickets)
            {
                if (custom_points == 40) return 60;
                if (custom_points == 80) return 120;
                if (custom_points == 120) return 180;
                if (custom_points == 160) return 240;
                return 320;
            }
            if (company_type == eObj.company_type_enum.house)
            {
                if (custom_points == 40) return 750;
                if (custom_points == 80) return 1500;
                if (custom_points == 120) return 2250;
                if (custom_points == 160) return 3000;
                return 3750;
            }
            if (company_type == eObj.company_type_enum.weapons)
            {
                if (custom_points == 40) return 60;
                if (custom_points == 80) return 120;
                if (custom_points == 120) return 180;
                if (custom_points == 160) return 240;
                return 300;
            }
            if (company_type == eObj.company_type_enum.hospital)
            {
                if (custom_points == 40) return 3450;
                if (custom_points == 80) return 6900;
                if (custom_points == 120) return 10350;
                if (custom_points == 160) return 13800;
                return 17250;
            }
            if (company_type == eObj.company_type_enum.defense_system)
            {
                if (custom_points == 40) return 3450;
                if (custom_points == 80) return 6900;
                if (custom_points == 120) return 10350;
                if (custom_points == 160) return 13800;
                return 17250;
            }

            return 0;
        }
            
    }
}
